package com.yanqu.road.entity.maidian;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.util.ArrayList;
import java.util.List;

@FieldTypeAnnotation(tableName = "t_u_maidian_login")
public class UserMaiDianLoginData extends DataObject {

    @FieldTypeAnnotation(desc = "玩家id", select = true, update = true)
    private long userId;

    @FieldTypeAnnotation(desc = "登录时间,记录当天的0点")
    private List<Long> loginTime = new ArrayList<>();

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public List<Long> getLoginTime() {
        return loginTime;
    }

    public void setLoginTime(List<Long> loginTime) {
        this.loginTime = loginTime;
        setUpdateOption();
    }

    public void addLoginTime(long time){
        if(!loginTime.contains(time)){
            loginTime.add(time);
            if(loginTime.size() > 5){
                loginTime.remove(0);
            }
            setUpdateOption();
        }
    }

    public void removeLoginTime(long time){
        if(loginTime.contains(time)){
            loginTime.remove(time);
            setUpdateOption();
        }
    }
}
